#include<iostream>
#include<cstdio>
using namespace std;
int n;
const int N = 1e4 + 10;
struct S
{
	int x, y, g, k;
	int id;
}s[N];
int main()
{
	int x, y, g, k;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d%d%d", &x, &y, &g, &k);
		s[i] = { x,y,g,k };
		s[i].id = i;
	}
	int t1, t2;
	scanf("%d%d", &t1, &t2);
	bool flag = 0;
	for (int i = n; i >= 1; i--) {
		int x1 = s[i].x;
		int x2 = x1 + s[i].g;
		int y1 = s[i].y;
		int y2 = y1 + s[i].k;
		if (x1 <= t1 && t1 <= x2 && y1 <= t2 && t2 <= y2) {
			printf("%d\n", s[i].id);
			flag = 1;
			break;
		}
	}
	if (!flag) {
		cout << -1 << endl;
	}
	return 0;
}